class Palindrome
{
    // Function to check if linked list is palindrome
    boolean isPalindrome(Node head) 
    {
        //Your code here
        Stack<Integer> st=new Stack<Integer>();
        
        Node temp=head;
        
        while(temp!=null)
        {
            st.push(temp.data);
            temp=temp.next;
        }
        while(head!=null)
        {
            if(head.data!=st.pop()){
                return false;
            }
            head=head.next;
        }
        return true;
    }    
}

